import httpUtils from "@/core/utils/http.utils";
import aesUtils from "@/core/utils/aes.utils";
// const authUrl = window.config.globalConfig.apiPath.auth;

// service path
const urls = {
  'getInfo': `/api/upms/sysUser/info`,
  'tenant': `/api/upms/sysRole/list`,
  'token': `/api/auth/oauth/token`,
  'menuUrl': `/api/upms/sysMenu`,
  'editUser': `/api/upms/sysUser/edit`,
  'logout': `/api/auth/token/logout`,
  // 获取安全策略
  'getSafePolicy': `/api/upms/sysDictItem/getSafePolicy`,
  //  磁盘告警
  'diskCheck': `/api/upms/diskCheck/dickAlarm`,
  // 获取注册信息
  'getSysRegister': `/api/upms/register/getRegInfo`,
  // 检查token值
  'checkTokenEx': `/api/upms/checkToken/isExpire`,

};
// service methods
const LoginSrv = {

  getToken(params = {}) {
    params.password = aesUtils.encode(params.password);
    return httpUtils.post(urls.token, params);
  },
  getTenant(params = {}) {
    return httpUtils.get(urls.tenant, params);
  },
  logout(username,roleCodes) {
    return httpUtils.delete(`${urls.logout}/${username}/${roleCodes}`, {});
  },
  editUser(params) {
    return httpUtils.putEncrypt(urls.editUser, params);
  },
  getInfo(params) {
    return httpUtils.get(urls.getInfo, params);
  },
  diskCheck(params) {
    return httpUtils.getEncrypt(urls.diskCheck, params);
  },
  getSafePolicy(params) {
    return httpUtils.getEncrypt(urls.getSafePolicy, params);
  },
  getProjAuthCount(params) {
    return httpUtils.get(urls.getProjAuthCount, params);
  },
  checkTokenEx(){
    return httpUtils.getAll(urls.checkTokenEx, {});
  },
  getServerTime(){
    return httpUtils.get(urls.serverTime, {});
  },

};


export default LoginSrv;
